package behavioral.observer;

/**
 * @ClassName: MainTest
 * @Description: 观察者模式测试类
 * @Author: liu-hao
 * @Date: 2023-04-09 10:41
 * @Version: 1.0
 **/
public class MainTest {

    public static void main(String[] args) {
        // 定义观察者对象
        Mum mum = new Mum();
        Dad dad = new Dad();
        Dog dog = new Dog();

        // 定义被观察者对象
        Child child = new Child();
        // 添加观察者
        child.registerObserver(mum);
        child.registerObserver(dad);
        child.registerObserver(dog);

        // 被观察者触发监测事件
        child.wakeUp();

        System.out.println("----------------------------------------------");
        // 移除一个观察者测试
        child.removeObserver(mum);
        child.wakeUp();
    }
}
